package ar.unrn.hibernate.jpa.main;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

import ar.unrn.hibernate.model.Student;

public class Main {

	public static void main(String[] args) {

		// Start EntityManagerFactory
		EntityManagerFactory emf = Persistence
				.createEntityManagerFactory("sample");
		// First unit of work
		EntityManager em = emf.createEntityManager();
		EntityTransaction tx = em.getTransaction();
		tx.begin();

		//do something
		Student angus = new Student("Angus", "Young");
		em.persist(angus);
		//	em.persist(message);
		tx.commit();
		em.close();

		// Shutting down the application
		emf.close();

	}
}
